import moduleRegist from '@/utils/moduleRegist';
import {
  module as instanceModule
} from './module';
const ListView = resolve => {
  require(['./ListView'], resolve);
};

const Layout = resolve => {
  require(['./Layout'], resolve);
};

const AddForm = resolve => {
  require(['./AddForm'], resolve);
};

const EditForm = resolve => {
  require(['./EditForm'], resolve);
};

export default [
  /** 配置管理路由 */
  {
    path: 'user',
    redirect: 'user/list',
    component: Layout,
    meta: {
      title: '用户',
      name: '用户',
      permission: 'auth:menu:user:list',
      componentName: 'UserLayout',
      keepAlive: true,
      icon: 'ios-person',
      show: false
    },
    beforeEnter: (to, from, next) => {
      moduleRegist(instanceModule);
      next();
    },
    children: [{
      path: 'list',
      component: ListView,
      meta: {
        title: '用户列表',
        name: '用户',
        breadcrumb: '用户列表',
        permission: 'auth:user:query',
        keepAlive: true,
        componentName: 'UserListView',
        icon: 'ios-person'
      }
    }, {
      path: 'add',
      component: AddForm,
      meta: {
        title: '添加用户',
        name: '添加用户',
        permission: 'auth:user:add',
        icon: 'ios-person',
        componentName: 'UserAddView',
        keepAlive: true,
        show: false
      }
    }, {
      path: 'edit/:id',
      component: EditForm,
      meta: {
        title: '修改用户',
        name: '修改用户',
        permission: 'auth:user:edit',
        icon: 'ios-person',
        show: false
      }
    }]
  }
];
